<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title></title>
</head>
<body>
<% 
long[] xvals = (long[])request.getAttribute("xvals");
double[] yvals = (double[])request.getAttribute("yvals");
if(xvals.length > 0){
	String sx = "[" + xvals[0];
	for(int i = 1; i < xvals.length; i++){
		sx += "," + xvals[i];
	}
	sx += "]";
	
	String sy = "[" + yvals[0];
	for(int i = 1; i < yvals.length; i++){
		sy += "," + yvals[i];
	}
	sy += "]";
	out.println("" + xvals.length + " resultaten gevonden!<br>");
	out.println("<input id=\"Button2\" type=\"button\" onclick='");
	out.println("	var graph = Raphael(document.getElementById(\"content\"), 800, 500);");
	out.println("	var options = {");
	out.println("			  axis: \"0 0 1 1\", // Where to put the labels (trbl)");
	out.println("			  axisxstep: 4 // How many x interval labels to render (axisystep does the same for the y axis)");
	out.println("			};");
	out.println("	var lines = graph.g.linechart(50,10,575,475," + sx + "," + sy + ",options);");
	out.println("	var xText = lines.axis[0].text.items;");
	out.println("		for(var i in xText){ // Iterate through the array of dom elems, the current dom elem will be i");
	out.println("		    var _oldLabel = (xText[i].attr(\"text\") + \"\"); // Get the current dom elem in the loop, and split it on the decimal");
	out.println("		    var l = parseInt(_oldLabel);");
	out.println("		    var d = new Date(l);");
	out.println("		    var _newLabel = d.getDate() + \"/\" + d.getMonth()+1 + \"/\" + d.getFullYear() + \" \" + d.toLocaleTimeString(); // Format the result into time strings");
	out.println("		    xText[i].attr({\"text\": _newLabel}); // Set the text of the current elem with the result");
	out.println("		  };");
	out.println("	' value=\"toon grafiek\" />");
	
}else{
	out.println("<h1>Geen waarden gevonden</h1>");
}
%>
</body>
</html>